package com.xywy.bloodandroid.act;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xywy.bloodandroid.R;
import com.xywy.bloodandroid.base.BaseActivity;
import com.xywy.bloodandroid.bean.User;

/**
 * 手机号
 */
public class PhoneNumberActivity extends BaseActivity {

	private TextView middle_title;
	private RelativeLayout left_img;
	private TextView tv_phone_number;
	private Button change_phone_number;

	@Override
	protected void initView(Bundle savedInstanceState) {
		setContentView(R.layout.activity_phone_number);
		change_phone_number = (Button) findViewById(R.id.change_phone_number);
		left_img = (RelativeLayout) findViewById(R.id.left_img);
		middle_title = (TextView) findViewById(R.id.middle_title);
		middle_title.setText("手机号");
		tv_phone_number = (TextView) findViewById(R.id.tv_phone_number);

	}

	@Override
	protected void initListener() {
		left_img.setOnClickListener(this);
		change_phone_number.setOnClickListener(this);
	}

	@Override
	protected void initData() {
		String phoneNum = User.getInstance(this).getPhonenum();
		if (phoneNum.length() != 11) {
			phoneNum = "暂时没有绑定手机号";
		} else {
			tv_phone_number.setText(phoneNum.substring(0, 3) + " "
					+ phoneNum.substring(3, 7) + " "
					+ phoneNum.substring(7, 11));
		}

	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		case R.id.left_img:
			PhoneNumberActivity.this.finish();
			break;

		case R.id.change_phone_number:
			enterActivity(ChanePhoneNumberActivity.class);
			break;
		}
	}

}
